home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / libs / graphics3d.lha / src / library / graphics3d2d_o.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-20  |  15.8 KB  |  717 lines

  1. /*
  2. **      $VER: graphics3D2d_o.c 10.00 (06.05.98)
  3. **
  4. **      Internal functions for graphics3D.library
  5. **     Optimezed 2D functions
  6. **    
  7. **      (C) Copyright 98 Patrizio Biancalani
  8. **      All Rights Reserved.
  9. */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/memory.h>
  13. #include <proto/exec.h>
  14. #include <proto/intuition.h>
  15. #include <intuition/intuition.h>
  16. #include <intuition/screens.h>
  17.  
  18. #include <graphics/rastport.h>
  19. #include <graphics/clip.h>
  20. #include <graphics/regions.h>
  21. #include <graphics/gfx.h>
  22. #include <graphics/gfxmacros.h>
  23. #include <graphics/layers.h>
  24.  
  25. #include "graphics3Dc.h"
  26. #include "graphics3D.h"
  27. #include "graphics3D2d_proto.h"
  28.  
  29.  /* Please note, that &Graphics3DBase always resides in register __a6 
  30.     as well, but if we don't need it, we need not reference it here.
  31.  
  32.     Also note, that registers a0, a1, d0, d1 always are scratch registers,
  33.     so you usually should only *pass* parameters there, but make a copy
  34.     directly after entering the function. To avoid problems of kind
  35.     "implementation defined behaviour", you should make a copy of A6 too,
  36.     when it is actually used.
  37.  
  38.     In this example case, scratch register saving would not have been 
  39.     necessary (since there are no other function calls inbetween), but we 
  40.     did it nevertheless.
  41.   */
  42.  
  43. struct pixl {
  44.     long int x;
  45.     long int y;
  46.     };
  47.  
  48. /************ prototipi solo locali ******/
  49. struct RastPort *InitNBuff(struct grafica *graf);
  50.  
  51. void FreeNBuff(struct grafica *graf);
  52.  
  53. /**********************************************************/
  54.  
  55. /************ macro solo locali ******/
  56. #define DIPIU 500 
  57. #define PREC 8
  58. /*************************************/
  59.  
  60. /****************************************************
  61.  ** Routin per la gestione della grafica, in stile **
  62.  ** 2.0 Ottimizzate                                ** 
  63.  ** (c) 1994 BIANCA HARD&SOFT Vers:1.00            **
  64.  ****************************************************/
  65.  
  66. /********* FUNZIONI DI INIZIALIZAZIONE PER IL 2D ********************************/
  67.  
  68. /***********************************
  69.  ** INIZIALIZZO STRUTTURE PER USO **
  70.  ** CON ROUTIN  OTTIMIZZATE.      **
  71.  ***********************************
  72.  **** INPUT :              **
  73.  ** win -> puntatore a finestra   **
  74.  **        su cui lavorare.       **
  75.  ** mxv -> n# massimo vertici da  **
  76.  **        usare.          **
  77.  ** dx -> larghezza box di visual.**
  78.  ** dy -> altezza box di visual.  **
  79.  **** OUTPUT :                    **
  80.  ** ris >0  - tutto ok.           **
  81.  ** ris =<0 - errore, ini.fallita.**
  82.  ***********************************/
  83. struct grafica *ini_g(struct Window *win,long int mxv,long int dx,long int dy)
  84. {
  85. struct grafica *ris;
  86. struct Screen *scr;
  87. struct RastPort *rw;
  88. struct RastPort *r;
  89. long int i;
  90.  
  91. ris=(struct grafica *)AllocMem(sizeof(Sgrafica),NULL);
  92. if (ris==NULL) return (0);
  93.  
  94. ris->vpor=0;
  95. ris->rast=0;
  96. ris->rast1=0;
  97. ris->rast2=0;
  98. ris->fdouble=1;
  99. ris->b_af=0;
  100. ris->pras=0;
  101.  
  102. /** default si single buffer **/
  103. ris->clipx=0;
  104. ris->clipy=0;
  105. i=((dx+15)/16)*16;
  106. ris->clipdx=i;
  107. ris->clipdy=dy;
  108. ris->dbuf=0;
  109. ris->ldbuf=0;
  110. ris->tmp_rp.BitMap=0;
  111.  
  112. rw=win->RPort;
  113. scr=win->WScreen;
  114. ris->vpor=&(scr->ViewPort);
  115. ris->wind=win;
  116.  
  117. r=InitNBuff(ris);
  118. if ((long int)r==NULL) {
  119.     close_g(ris);
  120.     return(0);
  121.     }
  122. ris->rast1=rw;
  123. ris->rast2=r;
  124. ris->rast=r;
  125.  
  126. return(ris);
  127. }
  128.  
  129. /***********************************
  130.  ** CHIUDO TUTTE LE STRUTTURE     **
  131.  ** APERTE CON LA FUNZIONE PRECE- **
  132.  ** DENTE.                        **
  133.  ***********************************
  134.  **** INPUT :                     **
  135.  ** graf -> valore >0 ritornato   **
  136.  **         dalla funzione d'ini- **
  137.  **         zializzazione         **
  138.  ***********************************/
  139. void close_g(struct grafica *graf)
  140. {
  141. struct RastPort *r;
  142. struct Layer *la;
  143. long int c;
  144.  
  145. if ((long int)graf != NULL)
  146.     {
  147.     if (graf->dbuf!=NULL) FreeNBuff(graf);
  148.     FreeMem(graf,sizeof(Sgrafica));
  149.     }
  150. }
  151.  
  152. /************************************
  153.  ** FUNZIONE PER VISUALIZZARE IL   **
  154.  ** DISPLAY BUFFER CHUNKY NELLA    **
  155.  ** FINESTRA.               **
  156.  ************************************
  157.  **** INPUT :               **
  158.  ** graf -> valore >0 ritornato    **
  159.  **         dalla funzione d'ini-  **
  160.  **         zializzazione.         **
  161.  **** OUTPUT:               **
  162.  ************************************/
  163. void switch_rp(graf)
  164. struct grafica *graf;
  165. {
  166. long int x,y;
  167.  
  168. x=graf->clipx;
  169. y=graf->clipy;
  170.  
  171. if (graf) WritePixelArray8(graf->rast,x,y,x+graf->clipdx-1,y+graf->clipdy-1,
  172.         graf->dbuf,&graf->tmp_rp);
  173.  
  174. }
  175.  
  176. /************************************
  177.  ** FUNZIONE PER DEFINIRE UN BOX   **
  178.  ** DI CLIP SULLA FINESTRA         **
  179.  ************************************
  180.  **** INPUT :               **
  181.  ** graf -> valore >0 ritornato    **
  182.  **         dalla funzione d'ini-  **
  183.  **         zializzazione.         **
  184.  ** minx - valore minimo x box.    **
  185.  ** miny - valore minimo y box.    **
  186.  ** dx - larghezza box.           **
  187.  ** dy - altezza box.           **
  188.  **** OUTPUT:               **
  189.  ** > 0 tutto ok, valore effettivo **
  190.  **     larghezza box in pixel.    ** 
  191.  ** = 0 errore.               **
  192.  **** NOTA:               **
  193.  ** elimina eventuali clip region  **
  194.  ** preesistenti.              **
  195.  ** Se dx o dy =0 allora ritorna   **
  196.  ** valore effettivo di dx.        **
  197.  ************************************/
  198. long int clipbox(struct grafica *graf,long int minx,
  199.            long int miny,long int dx,long int dy)
  200. {
  201. struct Layer *la;
  202. struct Region *clipr;
  203. struct Rectangle rect;
  204. struct ClipRect *clrt;
  205. long int esi;
  206. long int i;
  207.  
  208. #ifdef DEBUG
  209. char dbg[80];
  210. #endif
  211.  
  212. if (dx==0 OR dy==0) return(graf->clipdx);
  213.  
  214. i=((dx+15)/16)*16;
  215.  
  216. graf->clipx=minx;
  217. graf->clipy=miny;
  218.  
  219. /* se uso libreria ottimizzata */
  220. if (graf->clipdx!=i OR graf->clipdy!=dy)
  221.     {
  222.     graf->clipdx=i;
  223.     graf->clipdy=dy;
  224.     FreeNBuff(graf);
  225.     InitNBuff(graf);
  226.     }
  227.  
  228. return (graf->clipdx);
  229. }
  230.  
  231. /*************************************
  232.  ** FUNZIONE PER CANCELLARE UN BOX  **
  233.  ** NELLA FINESTRA .            **
  234.  *************************************
  235.  **** INPUT :                       **
  236.  ** graf -> valore >0 ritornato da  **
  237.  **         ini_g().                **
  238.  ** x0   -> coord. x punto in alto  **
  239.  **         a sinistra box.         **
  240.  ** y0   -> coord. y punto in alto  **
  241.  **         a sinistra box.         **
  242.  ** x1   -> coord. x punto in basso **
  243.  **         a destra box.        **
  244.  ** y1   -> coord. y punto in basso **
  245.  **        a destra box.        **
  246.  **** NOTA :                **
  247.  ** usa il colore dello sfondo, e   **
  248.  ** non influenza le altre funzioni **
  249.  *************************************/
  250. /*
  251. void cls_b(struct grafica *graf,long int x0,
  252.     long int y0,long int x1,long int y1)
  253. {
  254. long int i;
  255. char c,*db;
  256. if (((long int)graf<=NULL) OR ((long int)(graf->rast)<=NULL)) return(0); 
  257. EraseRect(graf->rast,x0,y0,x1,y1);
  258. }
  259. */
  260.  
  261. /*************************************
  262.  ** FUNZIONE PER CAMBIARE IL MODO   **
  263.  ** VIDEO DI TRACCIAMENTO.          **
  264.  *************************************
  265.  **** INPUT :                       **
  266.  ** graf -> valore >0 ritornato da  **
  267.  **         ini_g().                **
  268.  ** mod  -> nuovo modo video.       **
  269.  **** NOTA :                **
  270.  ** valori per mod :            **
  271.  ** 0 > JAM1 (over 2)            **
  272.  ** 1 > JAM2 (over 0) (def.)        **
  273.  ** 2 > COMPLEMENT (over 1)         **
  274.  ** 4 > INVERSVID  (inverse 1)      **
  275.  *************************************/
  276. void over(struct grafica *graf,long int mod)
  277. {
  278. if (((long int)graf<=NULL) OR ((long int)(graf->rast)<=NULL)) return(0); 
  279.  
  280. SetDrMd(graf->rast,mod);
  281. }
  282.  
  283. /********* ROUTIN INTERNE PER PSEUDO DOUBLE BUFFERING ***************/
  284. /*********************************************
  285.  ** INIZIALIZZO UN DISPLAY BUFFER DI TIPO   **
  286.  ** CHUNKY PER USARE POI WritePixelArray8().** 
  287.  *********************************************
  288.  **** INPUT :                    **
  289.  **** OUTPUT:                    **
  290.  ** se > 0 allora puntatore a nuova rastport**
  291.  *********************************************
  292.  ** nota: la larghezza del box di visualiz. ** 
  293.  **    deve essere un multiplo di 16.       **
  294.  *********************************************/
  295. struct RastPort *InitNBuff(struct grafica *graf)
  296. {
  297. struct RastPort *rport = NULL;  
  298. struct Window *win;
  299. short int err = NULL;
  300. char *c;
  301. unsigned char depth;
  302. long int i;
  303.  
  304. win=graf->wind;
  305.  
  306. graf->tmp_rp.BitMap=NULL;
  307. graf->dbuf=NULL;
  308.  
  309. InitRastPort(&graf->tmp_rp);
  310.  
  311. /** 
  312.    Uso le routin ottimizzate definisco un display buffer tipo chunky e una rastport temp.
  313.    per WritePixelArray8().
  314.    Nota :la larghezza del display buffer deve essere multipla di 16 (una word)).
  315. **/ 
  316. rport=win->RPort;
  317.  
  318. graf->ldbuf=graf->clipdx * graf->clipdy;
  319. graf->dbuf=(char *)AllocMem(graf->ldbuf+DIPIU,NULL);
  320. if (graf->dbuf==NULL) {
  321.     err=1;
  322.     goto NBInit_done ;
  323.     }
  324. graf->tmp_rp.Layer=NULL;
  325. graf->tmp_rp.BitMap=(struct BitMap *)AllocBitMap(graf->clipdx,1,8,                        BMF_CLEAR|BMF_DISPLAYABLE,rport->BitMap);
  326.  
  327. if (graf->tmp_rp.BitMap==NULL) {
  328.     err=2;
  329.     goto NBInit_done ;
  330.     }
  331.  
  332. /* inizializzo il display buffer con tutti 0 */
  333. c=graf->dbuf;
  334. for(i=0 ;i<graf->ldbuf; i++) c[i]=0;
  335.  
  336. NBInit_done:
  337. if (err) FreeNBuff(graf);
  338. return (rport);
  339. }
  340.  
  341. /***************************************************
  342.  ** CHIUDO TUTTE LE AREE APERTE DALLA InitNBuff() **
  343.  ***************************************************/
  344. void FreeNBuff(struct grafica *graf)
  345. {
  346.  
  347. if (graf->dbuf) FreeMem(graf->dbuf,graf->ldbuf + DIPIU);
  348. if (graf->tmp_rp.BitMap) 
  349.     {
  350.     WaitBlit();
  351.     FreeBitMap(graf->tmp_rp.BitMap);  
  352.     }
  353.  
  354. }
  355.  
  356. /********* FUNZIONI GRAFICHE 2D OTTIMIZZATE ********************************/
  357.  
  358. /***********************************
  359.  ** RIEMPIO IL DISPLAY FILE COL   **
  360.  ** COLORE DELLO SFONDO.      **
  361.  ***********************************
  362.  **** INPUT :              **
  363.  ** amb3d -> valore >0 ritornato  **
  364.  **         dalla funzione d'ini- **
  365.  **         zializzazione.        **
  366.  **** OUTPUT:              **
  367.  ** nessuno .              **
  368.  ***********************************/
  369. void cls_f(amb3d)
  370. struct ambient3d *amb3d;
  371. {
  372. char col,*c;
  373. long int i;
  374.  
  375. /* inizializzo il display buffer con gcolor */
  376. c=amb3d->graf->dbuf;
  377. col=amb3d->gcolor;
  378. for(i=0 ;i<amb3d->graf->ldbuf; i++) c[i]=col;
  379.  
  380. }
  381.  
  382. /***********************************
  383.  ** DISEGNO UN PIXEL NEL DISPLAY  **
  384.  ** BUFFER CHUNKY.          **
  385.  ***********************************
  386.  **** INPUT :              **
  387.  ** amb3d -> valore >0 ritornato  **
  388.  **         dalla funzione d'ini- **
  389.  **         zializzazione.        **
  390.  ** x  -> coordinata x .      **
  391.  ** y  -> coordinata y .      **
  392.  ** col-> colore pixel.          **
  393.  **** OUTPUT:              **
  394.  ** nessuno .              **
  395.  ***********************************/
  396. void pixel(amb3d,x,y,col)
  397. struct ambient3d *amb3d;
  398. short int x;
  399. short int y;
  400. long int col;
  401. {
  402. struct grafica *gf;
  403. short int dx;
  404. char *db;
  405.  
  406. gf=amb3d->graf;
  407. db=gf->dbuf;
  408. dx=gf->clipdx;
  409.  
  410. if (x>=NULL AND x<dx AND y>=NULL AND y<gf->clipdy) db[dx*y+x]=(char)col;
  411.  
  412. }
  413.  
  414. /***********************************
  415.  ** DISEGNO UNA RIGA NEL DISPLAY  **
  416.  ** BUFFER CHUNKY.          **
  417.  ***********************************
  418.  **** INPUT :              **
  419.  ** amb3d -> valore >0 ritornato  **
  420.  **         dalla funzione d'ini- **
  421.  **         zializzazione.        **
  422.  ** x  -> coordinata x partenza.  **
  423.  ** y  -> coordinata y partenza.  **
  424.  ** x1 -> coordinata x arrivo.      **
  425.  ** y1 -> coordinata y arrivo.      **
  426.  ** col-> colore riga.          **
  427.  **** OUTPUT:              **
  428.  ** nessuno .              **
  429.  ***********************************/
  430. void line(amb3d,x,y,x1,y1,col)
  431. struct ambient3d *amb3d;
  432. short int x;
  433. short int y;
  434. short int x1;
  435. short int y1;
  436. long int col;
  437. {
  438. struct grafica *gf;
  439. char *db;
  440. short int xm,ym,xx;
  441. long int xs,ys,xe,ye,dx,dy;
  442. long int xa,ya,xb,yb;
  443. long int ii,i,a,b;
  444.  
  445. #ifdef DEBUG
  446. char dbg[100];
  447. #endif
  448.  
  449. gf=amb3d->graf;
  450. db=gf->dbuf;
  451. xm=(short int)gf->clipdx;
  452. ym=(short int)gf->clipdy;
  453. xx=xm;
  454.  
  455. if (x==x1 AND y==y1) 
  456.     {
  457.     pixel(amb3d,x,y);
  458.     return(0);
  459.     }
  460.  
  461. xs=(long int)x<<PREC;
  462. xe=(long int)x1<<PREC;
  463. ys=(long int)y<<PREC;
  464. ye=(long int)y1<<PREC;
  465.  
  466. dy=ye-ys;
  467. dx=xe-xs;
  468. if (dy<NULL) dy=-dy;
  469. if (dx<NULL) dx=-dx;
  470. if (dy<dx)
  471.     {
  472.     dy=dy/(dx>>PREC);
  473.     if (ys>ye) dy=-dy;
  474.     a=ys;
  475.     xa=xs>>PREC;
  476.     xb=xe>>PREC;
  477.     ii=1;
  478.     if (xs>xe) ii=-1;
  479.     for(b=xa ;b!=xb ;b=b+ii) 
  480.         {
  481.         i=a>>PREC;
  482.         if (b>=0 AND b<xm AND i>=0 AND i<ym) db[i*xx+b]=(char)col;
  483.         a=a+dy;
  484.         }
  485.     }
  486. else
  487.     {
  488.     dx=dx/(dy>>PREC);
  489.     if (xs>xe) dx=-dx;
  490.     a=xs;
  491.     ya=ys>>PREC;
  492.     yb=ye>>PREC;
  493.     ii=1;
  494.     if (ys>ye) ii=-1;
  495.     for(b=ya ;b!=yb ;b=b+ii) 
  496.         {
  497.         i=a>>PREC;
  498.         if (b>=0 AND b<ym AND i>=0 AND i<xm) db[b*xx+i]=(char)col;
  499.         a=a+dx;
  500.         }
  501.     }
  502. }
  503.  
  504. /***********************************
  505.  ** DISEGNO UN TRIANGOLO CON O    **
  506.  ** SENZA BORDO NEL DISPLAY       **
  507.  ** BUFFER CHUNKY.          **
  508.  ***********************************
  509.  **** INPUT :              **
  510.  ** amb3d -> valore >0 ritornato  **
  511.  **         dalla funzione d'ini- **
  512.  **         zializzazione.        **
  513.  ** buf  -> puntatore ad array di **
  514.  **        short int con coordi- **
  515.  **         nate vertici.      **
  516.  ** col  -> short int con colore  **
  517.  **        triangolo.          **
  518.  ** bordo-> =-1 senza bordo       **
  519.  **         >=0 colore bordo.     **
  520.  **** OUTPUT:              **
  521.  ** nessuno .              **
  522.  ***********************************/
  523. void drw_t(amb3d,buf,col,bordo)
  524. struct ambient3d *amb3d;
  525. short int *buf;
  526. long int col;
  527. long int bordo;
  528. {
  529. short int i;
  530. long int ii;
  531. short int xa,xb,ya,yb,y;
  532. struct pixl *vert;
  533. long int xm,ym,x;
  534. long int dy,dx1,dx2,dx3,xs,xe,ys,ys1,ys2;
  535. struct grafica *gf;
  536. unsigned char *tmp;
  537. #ifdef DEBUG 
  538. char dbg[100];
  539. #endif
  540.  
  541. vert=(struct pixl *)amb3d->temp;
  542. gf=amb3d->graf;
  543. xm=gf->clipdx;
  544. ym=gf->clipdy;
  545. tmp=(unsigned char *)gf->dbuf;
  546.  
  547. vert[0].x=(long int)buf[0]<<PREC;
  548. vert[0].y=(long int)buf[1];
  549. vert[1].x=(long int)buf[2]<<PREC;
  550. vert[1].y=(long int)buf[3];
  551. vert[2].x=(long int)buf[4]<<PREC;
  552. vert[2].y=(long int)buf[5];
  553.  
  554. /* riordino i vertici in base alla Y minore con bubble sort */
  555. if (vert[0].y > vert[1].y)
  556.     {
  557.     x=vert[0].x;
  558.     y=vert[0].y;
  559.     vert[0].x=vert[1].x;
  560.     vert[0].y=vert[1].y;
  561.     vert[1].x=x;
  562.     vert[1].y=y;
  563.     }    
  564.  
  565. if (vert[1].y > vert[2].y)
  566.     {
  567.     x=vert[1].x;
  568.     y=vert[1].y;
  569.     vert[1].x=vert[2].x;
  570.     vert[1].y=vert[2].y;
  571.     vert[2].x=x;
  572.     vert[2].y=y;
  573.     }    
  574.  
  575. if (vert[0].y > vert[1].y)
  576.     {
  577.     x=vert[0].x;
  578.     y=vert[0].y;
  579.     vert[0].x=vert[1].x;
  580.     vert[0].y=vert[1].y;
  581.     vert[1].x=x;
  582.     vert[1].y=y;
  583.     }    
  584.  
  585. /** calcolo spostamenti su asse x per tutti i segmenti del triangolo **/
  586. /** valori in fix point (x256)                        **/
  587. ys=vert[0].y;
  588. ys1=vert[1].y;
  589. ys2=vert[2].y;
  590.  
  591. dy=ys1-ys;
  592. if (dy==NULL) dy=1;
  593. dx1=(vert[1].x-vert[0].x)/dy;
  594.  
  595. dy=ys2-ys;
  596. if (dy==NULL) dy=1;
  597. dx2=(vert[2].x-vert[0].x)/dy;
  598.  
  599. dy=ys2-ys1;
  600. if (dy==NULL) dy=1;
  601. dx3=(vert[2].x-vert[1].x)/dy;
  602.  
  603. xs=vert[0].x;
  604. xe=xs;
  605.  
  606. /** inizio tracciamenti **/
  607. ya=ys;
  608. yb=ys1;
  609.  
  610. for(y=ya ; y<=yb ; y++)
  611.     {
  612.     xa=xs>>PREC;
  613.     xb=xe>>PREC;
  614.     ii=y*xm;
  615.     if (y>=0 AND y<ym)
  616.         {
  617.         if (xa<xb) 
  618.             {
  619.             for (i=xa ;i<=xb ;i++) if (i>=0 AND i<xm) tmp[ii+i]=col;
  620.             }
  621.         else
  622.             {
  623.             for (i=xb ;i<=xa ;i++) if (i>=0 AND i<xm) tmp[ii+i]=col;
  624.             }
  625.         }
  626.     xs+=dx1;
  627.     xe+=dx2;
  628.     }
  629. /** traccio l'altra meta' del triangolo (se presente) **/
  630.  
  631. xs=vert[2].x;
  632. xe=xs;
  633.  
  634. ya=ys2;
  635. yb=ys1;
  636.  
  637. for(y=ya ; y>=yb ; y--)
  638.     {
  639.     xa=xs>>PREC;
  640.     xb=xe>>PREC;
  641.     ii=y*xm;
  642.     if (y>=0 AND y<ym)
  643.         {
  644.         if (xa<xb)
  645.             {
  646.             for (i=xa ;i<=xb ;i++) if (i>=0 AND i<xm) tmp[ii+i]=col;
  647.             }
  648.         else
  649.             {
  650.             for (i=xb ;i<=xa ;i++) if (i>=0 AND i<xm) tmp[ii+i]=col;
  651.             }
  652.         }
  653.     xs-=dx2;
  654.     xe-=dx3;
  655.     }
  656. /* traccio eventuale bordo */
  657.  
  658. if (bordo>=NULL)
  659.     {
  660.     line(amb3d,buf[0],buf[1],buf[2],buf[3],bordo);
  661.     line(amb3d,buf[2],buf[3],buf[4],buf[5],bordo);
  662.     line(amb3d,buf[4],buf[5],buf[0],buf[1],bordo);
  663.     }
  664.  
  665. }
  666.  
  667. /***********************************
  668.  ** DISEGNO UN QUADRILATERO CON O **
  669.  ** SENZA BORDO NELLA RASTPORT    **
  670.  ** NASCOSTA.              **
  671.  ***********************************
  672.  **** INPUT :              **
  673.  ** amb3d-> valore >0 ritornato   **
  674.  **         dalla funzione d'ini- **
  675.  **         zializzazione.        **
  676.  ** buf  -> puntatore ad array di **
  677.  **        short int con coordi- **
  678.  **         nate vertici.      **
  679.  ** col  -> short int con colore  **
  680.  **        triangolo.          **
  681.  ** bordo-> =-1 senza bordo       **
  682.  **         >=0 colore bordo.     **
  683.  **** OUTPUT:              **
  684.  ** nessuno .              **
  685.  ***********************************/
  686. void drw_q(amb3d,buf,col,bordo)
  687. struct ambient3d *amb3d;
  688. short int *buf;
  689. long int col;
  690. long int bordo;
  691. {
  692. struct grafica *gf;
  693. short int buf1[6];
  694.  
  695. gf=amb3d->graf;
  696. buf1[0]=buf[4];
  697. buf1[1]=buf[5];
  698. buf1[2]=buf[6];
  699. buf1[3]=buf[7];
  700. buf1[4]=buf[0];
  701. buf1[5]=buf[1];
  702.  
  703. drw_t(amb3d,buf,col,-1);
  704. drw_t(amb3d,buf1,col,-1);
  705. /* traccio eventuale bordo */
  706.  
  707. if (bordo>=NULL)
  708.     {
  709.     line(amb3d,buf[0],buf[1],buf[2],buf[3],bordo);
  710.     line(amb3d,buf[2],buf[3],buf[4],buf[5],bordo);
  711.     line(amb3d,buf[4],buf[5],buf[6],buf[7],bordo);
  712.     line(amb3d,buf[6],buf[7],buf[0],buf[1],bordo);
  713.     }
  714.  
  715. }
  716.  
  717.